const baseSize = 48;
// 设置 rem 函数
// function setRem() {
//   // 当前页面宽度相对于 750 宽的缩放比例，可根据自己需要修改。
//   const scale = document.documentElement.clientWidth / 750;
//   // 设置页面根节点字体大小
//   document.documentElement.style.fontSize =
//     baseSize * Math.min(scale, 2) + "px";
//   // document.documentElement.style.fontSize=`calc(100vw / 375)`
// }
function setRem() {
  var htmlDom = document.documentElement;
  var windowWidth = htmlDom.clientWidth;
  var proportion = 7.5;
  if (windowWidth >= 480) {
    windowWidth = 480;
  } else {
    proportion = 7.5;
  }
  var evt = "onorientationchange" in window ? "orientationchange" : "resize";
  htmlDom.style.fontSize = windowWidth / proportion + "px";
  (function () {
    document.addEventListener(
      "DOMContentLoaded",
      function () {
        if (!htmlDom.style.fontSize) {
          var htmlDomProtect = document.documentElement;
          var windowWidth = htmlDomProtect.clientWidth;
          if (windowWidth >= 480) {
            windowWidth = 480;
          } else {
            proportion = 7.5;
          }
          htmlDomProtect.style.fontSize = windowWidth / proportion + "px";
        }
      },
      false
    );
  })();

  window.addEventListener(
    evt,
    function () {
      setTimeout(function () {
        var htmlDomProtect = document.documentElement;
        var windowWidth = htmlDomProtect.clientWidth;
        if (windowWidth >= 480) {
          windowWidth = 480;
        } else {
          proportion = 7.5;
        }
        htmlDomProtect.style.fontSize = windowWidth / proportion + "px";
      }, 200);
    },
    false
  );
}
// 初始化
setRem();
// 改变窗口大小时重新设置 rem
// window.onresize = function () {
//   setRem();
// };
export {};
